#include <stdio.h>
#include <string.h>
#include "Message.h"
#include "Queue.h"
void msg_callback(void *data)
{
	printf("msg callback data:%d\n", *((uint32_t*)data));
}
int main(int argc, char const *argv[])
{
#ifndef LIST_QUEUE
	struct Queue * queue = (struct Queue *)CreateQueue(5, sizeof(struct Message));
	uint32_t data1 = 32;
	uint32_t data2 = 33;
	uint32_t data3 = 34;
	uint32_t data4 = 35;
	uint32_t data5 = 36;
	uint32_t data6 = 37;
	struct Message *msg = (struct Message *)CreateMessage(1, msg_callback, &data1);
	struct Message rmsg = {0};
	if (!PushQueue(queue, msg)) {
		printf("full...\n");
	}

	msg->what = 2;
	msg->data = (void*)&data2;
	if (!PushQueue(queue, msg)) {
		printf("full...\n");
	}

	msg->what = 3;
	msg->data = (void*)&data3;
	if (!PushQueue(queue, msg)) {
		printf("full...\n");
	}

	msg->what = 4;
	msg->data = (void*)&data4;
	if (!PushQueue(queue, msg)) {
		printf("full...\n");
	}

	msg->what = 5;
	msg->data = (void*)&data5;
	if (!PushQueue(queue, msg)) {
		printf("full...\n");
	}
	msg->what = 5;
	msg->data = (void*)&data6;
	if (!PushQueue(queue, msg)) {
		printf("full...\n");
	}



	while (PopQueue(queue, &rmsg)) {
		printf("what:%d \n",  rmsg.what);
		if (rmsg.callback) {
			rmsg.callback(rmsg.data);
		}
		memset(&rmsg, 0, sizeof(struct Message));
	}
#else
	struct Queue * queue = (struct Queue *)CreateQueue(5, sizeof(struct Message));
	ReleaseQueue(queue);
#endif
	return 0;
}